<template>
  <div class="layout">
    <nav class="navbar">
      <div class="logo">
        <i class="fab fa-java"></i>
        <div class="logo-text">Java<span>知识库</span></div>
      </div>
      
      <NavBar />
      
      <div class="nav-actions">
        <div class="search-box">
          <i class="fas fa-search"></i>
          <input type="text" placeholder="搜索Java知识点...">
        </div>
        <button class="theme-toggle" @click="themeStore.toggleTheme">
          {{ themeStore.currentTheme === 'light' ? '🌙' : '☀️' }}
        </button>
      </div>
    </nav>
    <main class="main-content">
      <slot></slot>
    </main>
  </div>
</template>

<script setup>
import { useThemeStore } from '../stores/theme'
import NavBar from './NavBar.vue'

const themeStore = useThemeStore()
</script>

<style scoped>
.layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 15px 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 2px 15px rgba(0,0,0,0.05);
}

.logo {
  display: flex;
  align-items: center;
}

.logo i {
  font-size: 32px;
  color: #f47a60;
  margin-right: 10px;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  color: #4a6baf;
}

.logo-text span {
  color: #f47a60;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.search-box {
  display: flex;
  align-items: center;
  background: #e9ecef;
  padding: 10px 20px;
  border-radius: 50px;
  width: 300px;
}

.search-box input {
  border: none;
  background: transparent;
  padding: 5px 10px;
  width: 100%;
  font-size: 16px;
  outline: none;
}

.search-box i {
  color: #6c757d;
}

.theme-toggle {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.main-content {
  flex: 1;
  padding-top: 80px; /* 为固定导航栏留出空间 */
}

@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    padding: 8px 16px;
  }

  .nav-actions {
    order: 3;
    margin-top: 20px;
    width: 100%;
    justify-content: center;
  }

  .search-box {
    width: 100%;
    margin-top: 20px;
  }
}
</style>
